package com.hz.zbl.controller;

import com.hz.zbl.model.dto.TeacherDTO;
import com.hz.zbl.model.request.ApiResponse;
import com.hz.zbl.service.TeacherService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class TeacherController {

    @Resource
    TeacherService teacherService;

    @GetMapping("/all-teachers")
    public String allTeachers(){

        return ApiResponse.ok(teacherService.allTeachers());
    }

    @PostMapping("/teacher-info")
    public String teacherInfo(@RequestParam("teacher_id") int teacher_id){
        TeacherDTO result = teacherService.getTeacherById(teacher_id);
        return result == null ? ApiResponse.intError() : ApiResponse.ok(result);
    }

}
